package com.burgeon.backend.EnterpriseWeChat.controller;

import com.burgeon.backend.EnterpriseWeChat.entity.ExpressCompany;
import com.burgeon.backend.EnterpriseWeChat.entity.YCOrder;
import com.burgeon.backend.EnterpriseWeChat.service.EWOrderService;
import com.burgeon.backend.stsutil.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;

@RestController
@CrossOrigin
@RequestMapping("ewapp/order")
public class EWOrderController extends EWBaseController {
    @Autowired
    private EWOrderService ewOrderService;

    /**
     * 订单详情
     * @return
     */
    @RequestMapping("GetRetailOutByOrderId")
    public ResponseResult<YCOrder> GetRetailOutByOrderId(String token, String ycOrderId){
        YCOrder data = ewOrderService.GetRetailOutByOrderId(token,ycOrderId);
        return new ResponseResult<>(SUCCESS,data);
    }

    /**
     * 查看物流公司
     * @param token
     * @return
     */
    @RequestMapping("getExpressCompany")
    public ResponseResult<ArrayList<ExpressCompany>> getExpressCompany(String token){
        ArrayList<ExpressCompany> data = ewOrderService.getExpressCompany(token);
        return new ResponseResult<>(SUCCESS,data);
    }

    /**
     * 发货
     * @param token
     * @param empName
     * @param expressName
     * @param expressNo
     * @param ycOrderId
     * @return
     */
    @RequestMapping("sendOrder")
    public ResponseResult<String> sendOrder(String token, String empName, String expressName, String expressNo, String ycOrderId){
        String data = ewOrderService.sendOrder(token, empName, expressName, expressNo, ycOrderId);
        return new ResponseResult<>(SUCCESS,data);
    }

    /**
     * 搜索订单号
     * @param token
     * @param docNo
     * @param storeId
     * @return
     */
    @RequestMapping("findOrderByDocNo")
    public ResponseResult< ArrayList<YCOrder>> FindOrderByDocNo(String token, String docNo, String storeId,String status){
        ArrayList<YCOrder> data = ewOrderService.FindOrderByDocNo(token, docNo,storeId,status);
        return new ResponseResult<>(SUCCESS,data);
    }


}
